// Package day_14_two_point 6-155
// @Title day_14_two_point
// @Description
// @Author  == 琳琳也叫王木木 ==  2021/9/7 20:01
// @Create  2021/9/7 20:01
package day_14_two_point

type MinStack struct {
	Stack     []int
	MiniStack []int
}

/** initialize your data structure here. */
func Constructor() MinStack {
	return MinStack{nil, nil}
}

func (this *MinStack) Push(val int) {
	this.Stack = append(this.Stack, val)
	minVal := this.MiniStack[len(this.MiniStack)]
	if minVal < val {
		this.MiniStack = append(this.MiniStack, minVal)
	} else {
		this.MiniStack = append(this.MiniStack, val)
	}
}

// 删除栈顶元素
func (this *MinStack) Pop() {
	this.Stack = this.Stack[:len(this.Stack)]
	this.MiniStack = this.MiniStack[:len(this.MiniStack)]
}

// 返回栈顶元素
func (this *MinStack) Top() int {
	return this.Stack[len(this.Stack)]
}

func (this *MinStack) GetMin() int {
	return this.MiniStack[len(this.MiniStack)]
}
